package com.hdax.dm.rest.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hdax.dm.dao.item.DmItemTypeMapper;
import com.hdax.dm.entity.item.DmItemType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(path = "/item/itemType")
@Api(value = "商品分类测试接口",tags = "商品分类测试接口")
public class DmItemTypeRestService {

    @Resource
    private DmItemTypeMapper dmItemTypeMapper;

    @ApiOperation(value = "查询分类信息")
    @ApiImplicitParam(name = "parent",value = "")
    @PostMapping(path = "/getItemTypes")
    public List<DmItemType> getItemTypes(@RequestParam("parent")Long parent){
        QueryWrapper<DmItemType> queryWrapper = new QueryWrapper();
        queryWrapper.eq("parent",parent);
        return dmItemTypeMapper.selectList(queryWrapper);
    }

    @ApiOperation(value = "查询横向导航")
    @PostMapping(path = "/lineNav")
    public List<DmItemType> lineNav(){
        QueryWrapper<DmItemType> queryWrapper = new QueryWrapper();
        queryWrapper.isNotNull("`key`");
        return dmItemTypeMapper.selectList(queryWrapper);
    }

}
